/**
 * @fileoverview   ajax/base  Ajax对象的定义
 * Created by fu.
 * Date: 12-2-1
 * Time: 上午10:23
 */
F.reg('ajax/base', function (f) {
    var win = window, doc = win['document'], docElement = doc.documentElement;
    /**
     * @name F.Ajax
     * @object
     * @namespace Ajax模块、直接使用 ajax.get,ajax.post发送请求
     *
     */

    var Ajax = {};


    function createXHR() {
        if (typeof XMLHttpRequest != "undefined") {
            createXHR = function () {
                return new XMLHttpRequest();
            };
        } else if (typeof ActiveXObject != "undefined") {
            createXHR = function () {
                if (typeof arguments.callee.activeXString != "string") {
                    var versions = ["MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.3.0",
                        "MSXML2.XMLHttp"];

                    for (var i = 0, len = versions.length; i < len; i++) {
                        try {
                            var xhr = new ActiveXObject(versions[i]);
                            arguments.callee.activeXString = versions[i];
                            return xhr;
                        } catch (ex) {
                            //skip
                        }
                    }
                }

                return new ActiveXObject(arguments.callee.activeXString);
            };
        } else {
            createXHR = function () {
                throw new Error("No XHR object available.");
            };
        }

        return createXHR();
    }

    Ajax.createXHR = createXHR;
    /**
     * @name F.Ajax.config
     * @object
     * @namespace Ajax配置
     * @example
     * 默认选项
     * {
     accepts: {
     xml: "application/xml, text/xml",
     html: "text/html",
     text: "text/plain",
     json: "application/json, text/javascript"
     },
     async:true,
     cache:true,
     param:{},
     url:'',
     dataType:'html',//xml,html,text,json,jsonp
     jsonpCallback:'',
     start:function(xhr){},
     complete:function(xhr){},
     error:function(xhr){},
     success:function(data,xhr){}
     }
     */
    Ajax.config = {
        accepts:{
            xml:"application/xml, text/xml",
            html:"text/html",
            text:"text/plain",
            json:"application/json, text/javascript"
        },
        async:true,
        cache:true,
        param:{},
        url:'',
        dataType:'html', //xml,html,text,json,jsonp
        jsonpCallback:'',
        start:function (xhr) {
        },
        complete:function (xhr) {
        },
        error:function (xhr) {
        },
        success:function (data, xhr) {
        }
    };
    return Ajax;


}, {

});